Skip to main content

Collimator Summary

Link to all documents regarding BSM2 model and wastewater treatment plant

Latest accounts and files

Collimator Accounts

  1. The main account is hydrotrek@gqc.com.
  2. Files are also shared with pavan@gqc.com.

Projects

  1. BSM2 - The main project. This is shared with the following accounts. bsm2

  2. BSM2 - backup - 3/21/23 A backup of the above BSM2 project created on 3/21/23 in hydrotrek@gqc.com users

  3. BSM2 - Copy - 2023-12-04 includes Brians changes to Vannary's original A copy in which Brian had made changes to the original BSM2. Created on 12/04/2023. users

  4. Hydrotrek_AI An older copy of the main project which contains some hybrid modeling changes. The latest AI related changes are present as a separate file under BSM2 project. See more details below. users

Downloaded project files

Collimator does not allow downloading the model files. Only data files (.csv in our case) and .py files are downloadable.

Downloaded data files are uploaded to the gdrive location here.

  • Collimator to TDEngine notebook
    • To displace collimator's result and matlab's result on Grafana.
    • matlab_output_cross_reference.csv (old filename: matlab_output_column_name.csv) contains the names of column in the matlab output file that are corresponding to the 16 variables of each submodel.
    • collimator_cross_reference_2022_12_08.csv (old filename: collimator_output_column_name_xxxx_xx_xx) contains the names of column in the colimator output file that created on 2022-12-08 or after that are corresponding to the 16 variables of each submodel.
    • The cross reference csv for different timestamp was created to match the column name of the 16 variables from the collimator output files that were created before 2022-12-08 because the blocks were renamed.
  • Compare the physical model results with hybrid model (bioreactor_1 AI) results

Model descriptions inside BSM2 project

NameTypeDescription
BSM2_DevelopModelBSM2 developing model. The current working version is the BSM2 physical model that uses python script block for flow combiner and Bioreactor_with_Integrator_as_a_Delay_Block submodels are used for bioreactor 1, 2 ,3 ,4, and 5 in the activated sludge.
BSM2_with_Bioreact_1_AIModelBSM2 with activated sludge (AS) bioreactor 1 is replaced with a time series AI model.
BSM2_Physical_ModelModelBSM2 model created based on BSM2 Matlab model.  Bioreactor_with_Integrator_as_a_Delay_Block submodels were used for bioreactors 1, 2, 3, 4, and 5 in the activated sludge
outdatedBSM2_with_the_First_Bioreactor_Block(incorrect)ModelBSM2 model with the old bioreactor submodels for bioreactor 1, 2, 3, 4, and 5 in the activated sludge.
Test_PyTorch_Model_LoadingModelTesting pytorch model loading
Test_Delay_BlockModelTesting the unit delay block by inputting different pulse width and period.
Test_Delay_Block_for_TSModelTesting the delay block for time series model
Test_Bioreactor_1_AIModelTesting time series bioreactor 1 AI model
Test_Mux_BlockModelTesting the mux block
Test_Bioreactor_with_Integrator_as_a_Delay_Block_SubmodelModelTesting the Bioreactor with Integrator as a delay block submodel
Test_Bioreactor_with_Integrator_as_a_Delay_Block_and_So_Control_SubmodelsModelTesting the Bioreactor with Integrator as a Delay Block and So Control submodels
Bioreactor_with_Unit_Delay_as_a_Delay_BlockSubmodelPhysical model of the bioreactor in the activated sludge. The unit delay block is used to break the algebraic loop when reading the Kla value back from the So control submodel.
Bioreactor_with_Integrator_as_a_Delay_BlockSubmodelPhysical model of the bioreactor in the activated sludge. The integrator block is used to break the algebraic loop when reading the Kla value back from the So control submodel.
Bioreactor_1_pySubmodelTime series model trained with bioreactor 1 input and output values.
T_Model_BlockSubmodelTemperature model block. User can choose between using ODE to get the temperature output or setting the output temperature to be equal to the input temperature. Declare Tmodel value to be more than 0.5 to use the ODE to get the output temperature.
ODE_Mass_Balance_BlockSubmodelGeneric ODE equation block for BSM2 variables. The block can be used to get soluble and particulate concentrations of different sub-processes.
TS_12_TimestepsSubmodelCreating an input array for time series model. The array contains the current and the previous 11-time steps value. If the current time step is less than 11, the variable's initial value will be used instead.
So_ControlSubmodelOxygen concentration control block

Different Saved versions inside BSM2 project

  • To access different saved version history of the model
    • click on the version history tab on the upper right corner version_history
Version HistoryModel/SubmodelDescription
pH_solver_ODE_for_7variablesBSM2_DevelopThe simulation was aborted due to time out. Unlike the previous version, all 7 variables inside pH solver block were solved using ODE.
pH_solver_for_ODE_only_one_variableBSM2_Develop The simulation was able to be completed. However, the outputs were different from Matlab outputs. In attempt to work around algebraic loop found in BSM2_model_problem_with_AlgebraicLoop, I converted the Sh2_solver and pH_solver from DAE to ODE. In this version, only Sh2 and H_ion ( 1 out of 7 variables) in pH ODE were solved. The other 6 variables were solved based on the H_ion.
completed_model_old_SO4_control_blockBSM2_DevelopFirst version of the completed BSM2 model with an old SO4 control block for bioreactor 4 and the first version of the bioreactor submodel.
new_SO4_control_block_new_bioreactor_1BSM2_DevelopModified bioreactor 1 block and SO4 control block.
replace_all_bioreactors_with_new_oneBSM2_DevelopReplaced bioreactor 1,2, 3, 4, and 5 with the modified bioreactors from the previous version (second version of bioreactor)
version_before_replacing_bioreactor_submodelBSM2_Developbioreactor 1, 2, 3, 4, and 5 with modified bioreactor models using the old submodel block
version_after_replacing_new_bioreactor_submodelsBSM2_DevelopReplaced bioreactor 1, 2, and 3 with Bioreactor_with_Unit_Delay_as_a_Delay_Block submodel (third version of bioreactor)
bioreactor_without_delay_block_for_1,2,3,and5BSM2_DevelopReplaced bioreactor 1, 2, 3, and 5 with Bioreactor_without_delay_block. Only bioreactor 4 contains the unit delay
bioreactor_with_intergrator_delayBSM2_DevelopReplaced bioreactor 1, 2, 3, 4, and 5 with Bioreactor_with_Integrator_as_a_Delay_Block submodels
bioreactor_with_intergrator_delay_new_flowcombinerBSM2_DevelopPrevious version with modified flowcombiner blocks
first_physical_modelBSM2_DevelopThe first version of the physical model before replacing the bioreactor 1 with AI model
with_Bioreactor_1_AIBSM2_DevelopReplaced  bioreactor 1 block with Bioreactor_1_py submodel. The bioreactor_1_py block has a  'soluble-particulate-t-TSTPlus-01-11-23 version.
Physical modelBSM2_DevelopThe most up to date version of the physical model
soluble-particulate-t-TSTPlus-01-11-23Bioreactor_1_pyUse this version to load soluble-particulate-t-TSTPlus-01-11-23.pkl model
soluble-particulate-t-inceptionTimePlus-01-11-23Bioreactor_1_pyUse this version to load soluble-particulate-t-inceptionTimePlus-01-11-23.pkl model

Input files

  • We use the dryinfluent dataset from MATLAB as our input to the model. They are the same input dataset to the MATLAB model.
  • The data has the time step of 15 min (0.0104 day).

Initialization Script

  • We can import py script to install certain python package to be used in python script block before starting the simulation runs. For an example, we need to pip install ipython tsai torch ipykernel before running BSM2_with_Bioreactor_1_AI model.

Description of csv files

nocsv filedescriptionlocation
1influent_Q_temp.csv*model's input flow and temperature. The data has a time step of 15 min (0.0104 days). The data is from MATLAB's BSM2 model dryinfluent dataset.Input of all types of BSM2 models
2influent_time_SI_SS_XI.csv*model's input Si and Ss and Xi. The data has a time step of 15 min (0.0104 days). The data is from MATLAB's BSM2 model dryinfluent dataset.Input of all types of BSM2 models
3influent_SO_SNO_SNH_SND.csv*model's input So, Sno, Snh, and Snh.  The data has a time step of 15 min (0.0104 days). The data is from MATLAB's BSM2 model dryinfluent dataset.Input of all types of BSM2 models
4influent_XND_SALK_TSS.csv*model's input Xnd, Salk, and TSS. The data has a time step of 15 min (0.0104 days). The data is from MATLAB's BSM2 model dryinfluent dataset.Input of all types of BSM2 models
5influent_XS_XBH_XBA_XP.csv*model's input Xs, Xbh, Xba, and Xp. The data has a time step of 15 min (0.0104 days). The data is from MATLAB's BSM2 model dryinfluent dataset.Input of all types of BSM2 models
6Particulate2TSS.csvthe ratio of  Xi, Xs, Xbh, Xba, and Xp convert to TSS at the end of the primary clarifier, bioreactors, activated sludge, thickener, and dewatering.uses in the python script block inside the particulate block of each process
7INTERFACEPAR.csvparameters used to convert activated sludge state variables to anaerobic digester state variables.found in ASM2ADM and ADM2ASM python script blocks inside an AnaerobicDigester/
8DIGESTERPAR.csvparameters used to calculate the reaction rate of the anaerobic digester state variables.found in reac, pH_solver, and mapping_output python script blocks inside AnaerobicDigester/ADM1_1
9DIGESTERPARINIT.csvinitial state of anaerobic digester state variablesuses in pH_solver inside AnaerobicDigester/ADM1_1
10Qbypass_split_param.csvcontain three types of bypass strategies and their control flow values.uses in Q_bypass_Plant_split python script block
11BIOREACTORPAR.csvparameters used to calculate the reaction rate of the state variables.uses in reac python script block inside all 3 types of bioreactor submodel
12AS_in_Q_T.csvActivated sludge influent flow and temperature values from MATLAB model. The values are the inputs to the test bioreactor 1 submodelinput of all types of test_Bioreactor submodel to simulate the run for bioreactor 1
13AS_in_soluble.csvActivated sludge influent soluble state variables values from MATLAB model. The values are the inputs to the test bioreactor 1 submodelinput of all types of test_Bioreactor submodel to simulate the run for bioreactor 1
14AS_in_particulate.csvActivated sludge influent particulate state variables values from MATLAB model. The values are the inputs to the test bioreactor 1 submodelinput of all types of test_Bioreactor submodel to simulate the run for bioreactor 1
15reac3_Q_T.csvBioreactor 3 influent flow and temperature values from MATLAB model. The values are the inputs to the test bioreactor 3 submodelinput of all types of test_Bioreactor submodel to simulate the run for bioreactor 3
16reac3_soluble.csvBioreactor 3 influent soluble state variables values from MATLAB model. The values are the inputs to the test bioreactor 3 submodelinput of all types of test_Bioreactor submodel to simulate the run for bioreactor 3
17reac3_particulate.csvBioreactor 3 influent particulate state variables values from MATLAB model. The values are the inputs to the test bioreactor 3 submodelinput of all types of test_Bioreactor submodel to simulate the run for bioreactor 3
18reac1_Q_T.csvBioreactor 1 influent flow and temperature values from MATLAB model. The values are the inputs to the test bioreactor 1 submodel. These values are the outputs of the hydraulic delay block.input of all types of test_Bioreactor submodel to simulate the run for bioreactor 1
19reac1_soluble.csvBioreactor 1 influent soluble state variables values from MATLAB model. The values are the inputs to the test bioreactor 1 submodel. These values are the outputs of the hydraulic delay block.input of all types of test_Bioreactor submodel to simulate the run for bioreactor 1
20reac1_particulate.csvBioreactor 1 influent particulate state variables values from MATLAB model. The values are the inputs to the test bioreactor 1 submodel. These values are the outputs of the hydraulic delay block.input of all types of test_Bioreactor submodel to simulate the run for bioreactor 1
21test_delay_time_series_input.csvinput data to test test_Delay_Block_for_TS submodel.input of test_Delay_Block_for_TS

* These csv can be combined into one file. The input csv was splitted into 5 different files because initially the dataloader could not read csv with more than four columns.

Description of py and pkl files

nopy/pkl filesdescriptionlocation
1intialization.pyselect this file under `INITIALIZATION SCRIPT` to 'pip tsai'  before the simulation.INITIALIZATION SCRIPT in the properties tab
2install_python_mods(1).pyselect this file under `INITIALIZATION SCRIPT` to  'pip install ipython tsai torch' before the simulation.INITIALIZATION SCRIPT in the properties tab
3install_python_mods.pyselect this file under `INITIALIZATION SCRIPT` to  'pip install ipython tsai torch ipykernel' before the simulation.INITIALIZATION SCRIPT in the properties tab
4soluble-particulate-t.pkloutdated time series models of Bioreactor 1 submodel.not used in any model
5soluble-particulate-t-InceptionTimePlus-01-11-23.pkltime series models of Biorector 1 submodel to predict the next state variable values  using the values from the previous 12 time stepsChoose soluble-particulate-t-InceptionTimePlus-01-11-23 Version of BIOREACTOR_1_PY located inside ActivatedSluge to use this model before starting the simulation
6soluble-particulate-t-TSTPlus-01-11-23.pkltime series models of Biorector 1 submodel to predict the next state variable values  using the values from the previous 12 time stepsChoose soluble-particulate-t-TSTPlus-01-11-23 Version of BIOREACTOR_1_PY located inside ActivatedSluge to use this model before starting the simulation